<?php js_validate();?>
<style type="text/css">
input,textarea,select{
	background-color:#fff; color:#000; background-color:#fff;	
}
</style>
<form id="form-validated" class="input" action="<?php echo $own_links;?>save" method="post" enctype="multipart/form-data">
		<input type="hidden" name="form_id" id="form_id" value="<?php echo isset($val->form_id)?$val->form_id:'';?>" />
        <a href="#" onclick="$('#table-form').hide();">Sembunyikan Form</a> &nbsp; <a href="#" onclick="$('#table-form').show();">Tampilkan Form</a>
		<table class="table-form" style="width:95%;" id="table-form" border="0">
			<tr>
				<td>Nama Principal</td>
				<td><input type="text" id="form_principal_name" name="form_principal_name" disabled="disabled" class="validate[required]"size="50" value="<?php echo isset($val->form_principal_name)?$val->form_principal_name:'';?>" /></td>
			</tr>
            <tr valign="top">
				<td>Alamat Principal</td>
				<td><textarea cols="50" rows="2" id="form_principal_address" disabled="disabled" name="form_principal_address" class="validate[required]" /><?php echo isset($val->form_principal_address)?$val->form_principal_address:'';?></textarea></td>
			</tr>
            <tr>
				<td>Nama Obligee</td>
				<td><input type="text" id="form_obligee_name" name="form_obligee_name" disabled="disabled" class="validate[required]"size="50" value="<?php echo isset($val->form_obligee_name)?$val->form_obligee_name:'';?>" /></td>
			</tr>
            <tr valign="top">
				<td>Alamat Obligee</td>
				<td><textarea cols="50" rows="2" id="form_obligee_address" disabled="disabled" name="form_obligee_address" class="validate[required]" /><?php echo isset($val->form_obligee_address)?$val->form_obligee_address:'';?></textarea></td>
			</tr>
            <!--<tr>
				<td>Nama Marketing</td>
				<td>
                	<select name="form_marketing" class="validate[required]" disabled="disabled" id="form_marketing">
                    	<option value="">Pilih Tipe Marketing</option>
                        <?php
							if(count($marketing) > 0){
								foreach($marketing as $r){
									$t = isset($val->form_marketing)?$val->form_marketing:"";
									$s = ($r->marketing_id==$t)?"selected='selected'":'';
									echo "<option value='".$r->marketing_id."' $s >".$r->marketing_name."</option>";
								}
							}
						?>
                    </select>
                </td>
			</tr>-->
			<input type="hidden" value="0" name="form_marketing" disabled="disabled" id="form_marketing" />
            <tr>
				<td>Tipe Bank Garansi</td>
				<td>
                	<select name="form_bank_garansi_type" class="validate[required]" disabled="disabled" id="form_bank_garansi_type">
                    	<option value="">Pilih Tipe Bank Garansi</option>
                        <option value="penawaran" <?php echo (isset($val->form_bank_garansi_type)&& $val->form_bank_garansi_type=="penawaran")?'selected="selected"':'';?>>Penawaran</option>
                        <option value="pelaksanaan" <?php echo (isset($val->form_bank_garansi_type)&& $val->form_bank_garansi_type=="pelaksanaan")?'selected="selected"':'';?> >Pelaksanaan</option>
                        <option value="uang muka" <?php echo (isset($val->form_bank_garansi_type)&& $val->form_bank_garansi_type=="uang muka")?'selected="selected"':'';?> >Uang Muka</option>
                        <option value="pemeliharaan" <?php echo (isset($val->form_bank_garansi_type)&& $val->form_bank_garansi_type=="pemeliharaan")?'selected="selected"':'';?> >Pemeliharaan</option>
                    </select>
                </td>
			</tr>
            <tr>
            	<td>Mata Uang</td>
                <td>
                	<select name="form_mata_uang" class="validate[required]" disabled="disabled" id="form_mata_uang">
                        <?php
							if(count($curr) > 0){
								foreach($curr as $r){
									$t = isset($val->form_mata_uang)?$val->form_mata_uang:"";
									$s = ($r->cur_id==$t)?"selected='selected'":'';
									echo "<option value='".$r->cur_id."' $s >".$r->cur_name."</option>";
								}
							}
						?>
                    </select>
                </td>
            </tr>
            <tr>
				<td>Nilai Project</td>
				<td>
                    <input type="text" id="form_contract_value" disabled="disabled" name="form_contract_value" class="validate[required,custom[onlyNumber]]"size="30" value="<?php echo isset($val->form_contract_value)?$val->form_contract_value:'';?>" /></td>
			</tr>
            <tr>
				<td>Nilai Jaminan</td>
				<td>                	
                    <input type="text" id="form_guarantee_value" disabled="disabled" name="form_guarantee_value" class="validate[required,custom[onlyNumber]]"size="30" value="<?php echo isset($val->form_guarantee_value)?$val->form_guarantee_value:'';?>" /></td>
			</tr>
            <tr>
				<td>Nomor Dokumen</td>
				<td><input type="text" id="form_document_number" disabled="disabled" name="form_document_number" class="validate[required]"size="50" value="<?php echo isset($val->form_document_number)?$val->form_document_number:'';?>" /></td>
			</tr>
            <tr valign="top">
				<td>Deskripsi Dokumen</td>
				<td><textarea cols="50" rows="2" id="form_document_desc" disabled="disabled" name="form_document_desc" class="validate[required]" /><?php echo isset($val->form_document_desc)?$val->form_document_desc:'';?></textarea></td>
			</tr>
            <tr valign="top">
				<td>Pekerjaan</td>
				<td>
                <textarea cols="50" id="form_job" disabled="disabled" name="form_job" class="validate[required]" rows="3"><?php echo isset($val->form_job)?$val->form_job:'';?></textarea>
			</tr>
            <tr>
				<td>Jangka Waktu</td>
				<td><input type="text" id="form_as_long_day" disabled="disabled" name="form_as_long_day" class="validate[required]"size="5" value="<?php echo isset($val->form_as_long_day)?$val->form_as_long_day:'';?>" /> Hari</td>
			</tr>
            <tr>
				<td>Mulai Tanggal </td>
				<td><input type="text" id="form_start_date" name="form_start_date" disabled="disabled" class="validate[required] picker" readonly="readonly" size="15" value="<?php echo isset($val->form_start_date)?$val->form_start_date:'';?>" /> s/d <input type="text" id="form_end_date" name="form_end_date" class="validate[required] picker" disabled="disabled" readonly="readonly" size="15" value="<?php echo isset($val->form_end_date)?$val->form_end_date:'';?>" /></td>
			</tr>                   
			
			<tr valign="top">
				<td>Dokumen </td>
				<td>
						 <div id="formulir_files"></div>
                         <?php if(isset($files) && count($files) > 0){
							 	$nomor = 1;
								foreach($files as $r){
								?>
									<div class="file"><?php echo $nomor;?>. 
                                    	<a href="#" class="file_item">Dokumen Pendukung </a>
                                        <a href="<?php echo base_url()."uploaded/formulir/".$r->file_location.$r->file_name;?>" class="download_item" target="_blank">[ download ]</a>
                                    </div>
								<?php
									$nomor++;
								}
						 }?>
                </td>
			</tr> 			
       </table>
       <table  class="table-form" style="width:95%;" border="0">
       		<tr>
            	<td colspan="2">
                	<fieldset style="padding:5px; margin-top:20px;"> 
                        <legend style="padding:5px 15px; background-color:#222; color:#fff;">Silahkan Approve Salah Satu Asuransi</legend>
                            <?php 
                                if (count($items) > 0){
                                    ?>
                                    <table width="100%" class="data">
                                        <tr>
                                            <th>No</th>
                                            <th>Asuransi</th>
                                            <th>Status</th>
                                            <th>Note</th>
                                            <th>Approve?</th>
                                        </tr>
                                    <?php
                                    $nom=0;
                                    foreach($items as $v){
                                        ?>
                                        <tr>
                                            <td><?php echo ++$nom;?></td>
                                            <td><?php echo $v->asuransi_name;?></td>
                                            <td><?php echo $v->as_status;?></td>
                                            <td><input type="text" class="" <?php echo $this->dis;?> id="note_<?php echo $v->as_asuransi_id;?>" size="50" name="note[<?php echo $v->as_asuransi_id;?>]" /></td>
                                            <td><input type="radio" <?php echo $this->dis;?> size="50" <?php echo ($nom==1)?'checked="checked"':'';?> name="rd_approve" value="<?php echo $v->as_asuransi_id;?>" />
                                            </td>
                                        </tr>
                                        <?php
                                    }
                                    ?>
                                    </table>
                                    <?php
                                }
                            ?>
                            
                        </fieldset> 
                </td>
            </tr>
       		<tr>
				<td><input type="reset" onclick="document.location='<?php echo $own_links;?>'" class="btnbatal" value="Batal" /></td>
				<td align="right">
                <?php if($this->is_detail==FALSE){ ?>
                <input type="submit" class="btnsimpan" value="Simpan" />
                <?php } ?>
                </td>
			</tr>
       </table>
	</form>

<script language="javascript">
$('#link_tambah').click(function(a){
	rd=Math.floor(Math.random()*1000000);
	html = create_obj(rd);
	$('#formulir_files').append(html);
});

function create_obj(id){
	n_id = "id_"+id;
	obj = "<input type='file' name='formulir_files"+n_id+"' size='30' />";
	return "<div id='div_"+n_id+"' style='margin:4px 0px;'>"+obj+"<a href='#' id='li_"+n_id+"' onClick=_hapus_item('"+n_id+"')><img src='"+THEME_URL+"images/deleteo.png' /></a></div>";	
}
function _hapus_item(i){
	$('#div_'+i).fadeOut("medium",function(){
		$(this).remove(); 
	});
}

</script>